package com.hudongwx.shansun.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.hudongwx.shansun.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_opition)
public class OpitionActivity extends AppCompatActivity {
    @ViewInject(R.id.opitiion_et)
    private EditText editText;
    @ViewInject(R.id.opitiion_tv_1)
    private TextView tv1;
    private int page = 0;

    private String TAG = "OpitionActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        editText.addTextChangedListener(new TextWatcher() {


            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {


            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {


            }

            @Override
            public void afterTextChanged(Editable s) {
                int number = s.length();
                if (number <= 500) {
                    tv1.setText(number + "");

                } else {
                    Toast.makeText(OpitionActivity.this, "超过内容", Toast.LENGTH_SHORT).show();
                }


            }
        });
    }

    @Event(R.id.opitiion_btn)
    private void btn(View view) {
        if (!TextUtils.isEmpty(editText.getText()+"")) {
            Toast.makeText(OpitionActivity.this, "你未登陆", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(this, LoginActivity.class));
        } else {
            Toast.makeText(OpitionActivity.this, "请输入内容", Toast.LENGTH_SHORT).show();
        }

    }

    @Event(R.id.opitiion_iv)
    private void imgBtn(View view) {
        finish();
    }

}
